Replace all our Python linters with ruff
Categories
(Developer Infrastructure :: Lint and Formatting, task)
Tracking
(firefox113 fixed)
Tracking | Status | |
---|---|---|
firefox113 | --- | fixed |
People
(Reporter: ahal, Assigned: ahal)
References
(Blocks 1 open bug)
Details
Attachments
(4 files, 2 obsolete files)
Ruff is a newish tool that's making some waves in the Python community. It's written in Rust and can replace a huge number of existing Python tooling. It has some pretty compelling selling points:
Ruff can be used to replace Flake8 (plus a variety of plugins), isort, pydocstyle, yesqa, eradicate, pyupgrade, and autoflake, all while executing tens or hundreds of times faster than any individual tool.
Autofix support, for automatic error correction
Would solve our clunky autopep8
acting as flake8
's "fixer" problem
10-100x faster than existing linters
Our Python linting story is a bit of a mess, and this tool looks like a promising way to collapse all our rules into a single speedy linter. It even supports flake8's per-file-ignores
feature, which means we'd have that capability for things like isort
and pyupgrade
as well!
Comment 1•2 years ago
|
||
ah ah, I was opening a bug for this :)
More info:
https://notes.crmarsh.com/ruff-the-first-200-releases
Assignee | ||
Comment 2•2 years ago
|
||
Since filing this I've used ruff in a few projects and have spent a decent amount of time looking at the docs. I'm convinced this is something we should do. I'm going to see how far I get here without putting too much effort in.
Assignee | ||
Comment 3•2 years ago
|
||
Assignee | ||
Comment 4•2 years ago
|
||
Depends on D172313
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 5•2 years ago
|
||
This is enabling the PLE and PLC rules across a much larger swatch of the code
base. The PLR and PLW are additionally enabled at the warning level (introduces
~2500 new warnings).
To avoid extraneous changes in people's patches, rules at the warning level are
excluded from --fix.
Depends on D172348
Assignee | ||
Comment 6•2 years ago
|
||
Depends on D172358
Assignee | ||
Comment 7•2 years ago
|
||
Depends on D172359
Assignee | ||
Comment 8•2 years ago
|
||
Depends on D172360
Comment 9•2 years ago
|
||
Comment on attachment 9322565 [details]
WIP: Bug 1811850 - [lint] Enable pyupgrade rules in ruff, r#linter-reviewers
Revision D172360 was moved to bug 1715287. Setting attachment 9322565 [details] to obsolete.
Comment 10•2 years ago
|
||
Comment on attachment 9322566 [details]
WIP: Bug 1811850 - [lint] Fix pyupgrade lint errors from new configuration, r#linter-reviewers
Revision D172361 was moved to bug 1715287. Setting attachment 9322566 [details] to obsolete.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 11•2 years ago
|
||
Comment 12•2 years ago
|
||
Backed out for causing linting bustages(bugzilla)
- Backout link
- Push with failures
- Failure Log
- Failure line: FileToBugzillaMappingError: Missing Bugzilla component: pyproject.toml - Set the BUG_COMPONENT in the moz.build file to fix the issue.
Assignee | ||
Updated•2 years ago
|
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/5dfcd5a1b685
https://hg.mozilla.org/mozilla-central/rev/1f236421121c
https://hg.mozilla.org/mozilla-central/rev/75ff6a88978b
https://hg.mozilla.org/mozilla-central/rev/bd79cf7201c7
Comment 15•1 year ago
|
||
This did not replace the formatter we use (black), do we want to replace it too?
Assignee | ||
Comment 16•1 year ago
|
||
Yeah, at the time this was filed Ruff's formatter wasn't ready. But AIUI it is now more or less a drop-in replacement for Black as well. I'm on board with switching, but let's file a new bug.
Description
•